package com.foo.designpattern.iterator;

import java.util.ArrayList;
import java.util.List;

/**
 * com.foo.designpattern.iterator
 * Created with IntelliJ IDEA.
 * Created by jiang on 2016-05-31 13:45.
 *
 * @Description 具体聚集(ConcreteAggregate)角色
 * 具体聚集角色：实现了抽象聚集角色类所要求的接口
 */

public class ConcreteAggregate implements Aggregate {
    // 声明一个List泛型变量，用于存放聚集对象
    private List<Object> items = new ArrayList<Object>();

    @Override
    public Iterator CreateIterator() {
        return new ConcreteIterator(this);
    }

    // 返回集合总个数
    public int count() {
        return items.size();
    }

    public List<Object> getItems() {
        return items;
    }

    public void setItems(List<Object> items) {
        this.items = items;
    }
}
